package generator;


import model.Model;

import org.jgrapht.ListenableGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.ListenableDirectedGraph;


public class GraphGenerator extends Generator{

	//private UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
	private ListenableGraph<String, DefaultEdge> g;
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public GraphGenerator(Model m) {
		super(m);
		g = new ListenableDirectedGraph( DefaultEdge.class );
	}
	
	@Override
	public boolean generate() {
		for(model.Class c : model.getClasses()){
			g.addVertex(c.getName());
		}
		for(model.Class c : model.getClasses()){
			if(g.containsVertex(c.getParent()))
				g.addEdge(c.getName(), c.getParent());
		}
		return false;
	}
    
    public ListenableGraph<String, DefaultEdge> getGraph(){
    	return g;
    }
}
